 package server.life;

 import client.skills.SkillFactory;
 import client.status.MonsterStatus;
 import client.status.MonsterStatusEffect;
 import java.awt.Point;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 import server.MapleStatEffect;
 import server.maps.MapleMap;
 import server.maps.MapleSummon;
 import tools.MaplePacketCreator;

 public class SpawnPoint
   extends Spawns
 {
   private final MapleMonsterStats monster;
   private final Point pos;
   private final int mobTime;
   private final int fh;
   private final int f;
   private final int id;
/*  23 */   private final AtomicInteger spawnedMonsters = new AtomicInteger(0);
   private final String msg;
   private final byte carnivalTeam;
   private long nextPossibleSpawn;
/*  27 */   private int carnival = -1;
/*  28 */   private int level = -1;

   public SpawnPoint(MapleMonster monster, Point pos, int mobTime, byte carnivalTeam, String msg) {
/*  31 */     this.monster = monster.getStats();
/*  32 */     this.pos = pos;
/*  33 */     this.id = monster.getId();
/*  34 */     this.fh = monster.getFh();
/*  35 */     this.f = monster.getF();
/*  36 */     this.mobTime = (mobTime < 0) ? -1 : (mobTime * 1000);
/*  37 */     this.carnivalTeam = carnivalTeam;
/*  38 */     this.msg = msg;
/*  39 */     this.nextPossibleSpawn = System.currentTimeMillis();
   }

   public void setCarnival(int c) {
/*  43 */     this.carnival = c;
   }

   public void setLevel(int c) {
/*  47 */     this.level = c;
   }


   public int getF() {
/*  52 */     return this.f;
   }


   public int getFh() {
/*  57 */     return this.fh;
   }


   public Point getPosition() {
/*  62 */     return this.pos;
   }


   public MapleMonsterStats getMonster() {
/*  67 */     return this.monster;
   }


   public byte getCarnivalTeam() {
/*  72 */     return this.carnivalTeam;
   }


   public int getCarnivalId() {
/*  77 */     return this.carnival;
   }


   public boolean shouldSpawn(long time) {
/*  82 */     if (this.mobTime < 0) {
/*  83 */       return false;
     }


/*  87 */     return (((this.mobTime == 0 && this.monster.isMobile()) || this.spawnedMonsters.get() <= 0) && this.spawnedMonsters.get() <= 1 && this.nextPossibleSpawn <= time);
   }


   public MapleMonster spawnMonster(MapleMap map) {
/*  92 */     MapleMonster mob = new MapleMonster(this.id, this.monster);
/*  93 */     mob.setPosition(this.pos);
/*  94 */     mob.setCy(this.pos.y);
/*  95 */     mob.setRx0(this.pos.x - 50);
/*  96 */     mob.setRx1(this.pos.x + 50);
/*  97 */     mob.setFh(this.fh);
/*  98 */     mob.setF(this.f);
/*  99 */     mob.setCarnivalTeam(this.carnivalTeam);
/* 100 */     if (this.level > -1) {
/* 101 */       mob.changeLevel(this.level);
     }
/* 103 */     this.spawnedMonsters.incrementAndGet();
/* 104 */     mob.addListener(() -> {
           this.nextPossibleSpawn = System.currentTimeMillis();

           if (this.mobTime > 0) {
             this.nextPossibleSpawn += this.mobTime;
           }
           this.spawnedMonsters.decrementAndGet();
         });
/* 112 */     map.spawnMonster(mob, -2);
/* 113 */     for (MapleSummon s : map.getAllSummonsThreadsafe()) {
/* 114 */       if (s.getSkillId() == 35111005) {
/* 115 */         MapleStatEffect effect = SkillFactory.getSkill(s.getSkillId()).getEffect(s.getSkillLevel());
/* 116 */         for (Map.Entry<MonsterStatus, Integer> stat : (Iterable<Map.Entry<MonsterStatus, Integer>>)effect.getMonsterStati().entrySet()) {
/* 117 */           mob.applyStatus(s.getOwner(), new MonsterStatusEffect(stat.getKey(), stat.getValue(), s.getSkillId(), null, false, 0), false, effect.getDuration(), true, effect);
         }
         break;
       }
     }
/* 122 */     if (this.msg != null) {
/* 123 */       map.broadcastMessage(MaplePacketCreator.serverNotice(6, this.msg));
     }
/* 125 */     return mob;
   }


   public int getMobTime() {
/* 130 */     return this.mobTime;
   }
 }


/* Location:              C:\PGX\Server.jar!\server\life\SpawnPoint.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */